Graphics consist of:
Both the structure and aesthetics should help viewers interpret the information.
Color is context-sensitive: A and B are the same intensity and hue, but appear to be different.
ggplot2Main parameters: alpha, shape, color, size
Find ways to improve the following graphic:
frame <- read.csv("http://heike.github.io/rwrks/02-r-graphics/data/frame.csv")
qplot(x, y, data = frame, shape = g1, colour = g2, size = I(4))interaction combines factor variablesWhich is bigger?
Qualitative schemes: no more than 7 colors
Quantitative schemes: use color gradient with only one hue for positive values
Quantitative schemes: use color gradient with two hues for positive and negative values. Gradient should go through a light, neutral color (white)
Small objects or thin lines need more contrast than larger areas
R package based on Cynthia Brewer’s color schemes (http://www.colorbrewer2.org)
display.brewer.all()ggplot2scale_colour_discretescale_colour_brewer(palette = ...)scale_colour_gradient (define low, high values)scale_colour_gradient2 (define low, mid, and high values)scale_fill_...qplot(carat, price, shape = cut, colour = clarity, data = diamonds)facets = row ~ col Use . if there is no variable for either row or column (i.e. facets = . ~ col)qplot(price, carat, data = diamonds, color = color, facets = . ~ clarity)The movies dataset contains information from IMDB.com including ratings, genre, length in minutes, and year of release.
movies <- read.csv("http://heike.github.io/rwrks/02-r-graphics/data/MovieSummary.csv")